package tt.dz.biz.service.rpc;

import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Resource;
import org.apache.avro.Protocol;
import org.apache.avro.Protocol.Message;
import org.apache.avro.generic.GenericRecord;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tt.dz.biz.dao.account.AccountingDAO;
import tt.dz.biz.dao.financial.MerchantDAO;
import tt.dz.biz.dao.order.OrderServiceDAOImpl;
import tt.dz.biz.dao.trade.TradeDAOImpl;
import tt.dz.biz.dao.user.IdentityAccountDAO;
import tt.dz.biz.dao.user.OnlineAccountDAO;
import tt.dz.biz.dao.user.UserDAOImpl;
import tt.dz.biz.service.card.CardTypeService;
import tt.dz.biz.service.channel.PayChannelService;
import tt.dz.biz.service.common.CommonService;
import tt.dz.common.BigDecimalUtil;
import tt.dz.common.BusinessException;
import tt.dz.common.DZStringUtil;
import tt.dz.common.DateUtil;
import tt.dz.common.DzConstants;
import tt.dz.common.DzConstants.CardType;
import tt.dz.common.DzConstants.PayType;
import tt.dz.common.DzConstants.accountingState;
import tt.dz.common.DzConstants.isSelfMerchant;
import tt.dz.common.DzConstants.orderType;
import tt.dz.common.DzConstants.payState;
import tt.dz.common.DzConstants.userType;
import tt.dz.common.DzErrorCode;
import tt.dz.common.DzErrorCode.CardErrorCode;
import tt.dz.common.DzErrorCode.ChannelErrorCode;
import tt.dz.common.DzErrorCode.CommonErrorCode;
import tt.dz.common.DzErrorCode.MerchErrorCode;
import tt.dz.common.DzErrorCode.TranErrorCode;
import tt.dz.common.LogUtil;
import tt.dz.vo.IdentityAccountVO;
import tt.dz.vo.MerchantVO;
import tt.dz.vo.OnlineAccountVO;
import tt.dz.vo.OrderServiceVO;
import tt.dz.vo.OutOfflineCardMerchant;
import tt.dz.vo.PayChannelVO;
import tt.dz.vo.TranInfoVO;
import tt.dz.vo.TranSubVO;
import tt.dz.vo.UserBaseVO;

@Service("rpcTradeService")
public class RPCTradeService
  implements RPCBaseService
{
  @Resource(name="commonService")
  private CommonService commonService;
  @Resource(name="userDAO")
  private UserDAOImpl userDAOImpl;
  @Resource(name="merchantDAO")
  private MerchantDAO merchantDAO;
  @Resource(name="identityAccountDAO")
  private IdentityAccountDAO dentityAccountDAO;
  @Resource(name="orderServiceDAO")
  private OrderServiceDAOImpl orderService;
  @Resource(name="cardTypeServiceImpl")
  private CardTypeService cardTypeService;
  @Resource(name="accountingRuleDAO")
  AccountingDAO accountingDAO;
  @Resource(name="onlineAccountDAO")
  private OnlineAccountDAO onlineAccountDAO;
  @Resource(name="tradeDAO")
  private TradeDAOImpl tradeDAO;
  @Resource(name="payChannelService")
  private PayChannelService payChannelService;
  @Resource(name="cardTypeServiceImpl")
  private CardTypeService cardTypeServiceImpl;
  private static final Map<String, String> REQUIRE_PROPERTY_MAP = new HashMap()
  {
    private static final long serialVersionUID = 8375738807738748036L;
  };
  
  public Object execute(Protocol.Message message, Object request, Protocol protocol)
    throws Exception
  {
    JSONObject resultJson = new JSONObject();
    try
    {
      Object req = ((GenericRecord)request).get("req");
      String tradeReq = req.toString();
      List<TranInfoVO> tranInfoList = JSONObject.parseArray(tradeReq, TranInfoVO.class);
      for (TranInfoVO tranInfoVO : tranInfoList)
      {
        for (Map.Entry<String, String> entry : REQUIRE_PROPERTY_MAP.entrySet()) {
          if (StringUtils.isBlank(BeanUtils.getProperty(tranInfoVO, (String)entry.getKey())))
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", entry.getValue());
            resultJson.put("errorCode", DzErrorCode.CommonErrorCode.PARAM_REQUIRED.value());
            return resultJson.toJSONString();
          }
        }
        if ((null != tranInfoVO.getOrderType()) && 
          (!DzConstants.orderType.ADVANCE_PAYMENT.value().equals(tranInfoVO.getOrderType())) && 
          (!DzConstants.orderType.AFTER_PAYMENT.value().equals(tranInfoVO.getOrderType())))
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", "订单类型错误。");
          resultJson.put("errorCode", DzErrorCode.CommonErrorCode.PARAM_FORMAT_ERROR.value());
          return resultJson.toJSONString();
        }
        if (StringUtils.isBlank(tranInfoVO.getCardType()))
        {
          String cardType = this.cardTypeServiceImpl.getCardType(tranInfoVO.getCardNo());
          tranInfoVO.setCardType(cardType);
        }
        OrderServiceVO serviceVO = this.orderService.queryServiceByCode(tranInfoVO.getServiceNo());
        if (null == serviceVO)
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", DzErrorCode.TranErrorCode.SERVICE_NOT_FOUND.getDesc() + ",服务编码为：" + tranInfoVO.getServiceNo());
          resultJson.put("errorCode", DzErrorCode.TranErrorCode.SERVICE_NOT_FOUND.value());
          return resultJson.toJSONString();
        }
        if (tranInfoVO.getAppId().length() > 3)
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", DzErrorCode.CommonErrorCode.PARAM_TOO_LARGE.getDesc() + ",appId只能3位。");
          resultJson.put("errorCode", DzErrorCode.CommonErrorCode.PARAM_TOO_LARGE.value());
          return resultJson.toJSONString();
        }
        if ((DzConstants.PayType.THIRD_REALTIME_PAY.value().equals(tranInfoVO.getPayTypeCode())) && (
          (StringUtils.isBlank(tranInfoVO.getChannelCode())) || (StringUtils.isBlank(tranInfoVO.getThdPaySeq())) || 
          (null == tranInfoVO.getThdEndTime())))
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", DzErrorCode.CommonErrorCode.PARAM_REQUIRED.getDesc());
          resultJson.put("errorCode", DzErrorCode.CommonErrorCode.PARAM_REQUIRED.value());
          return resultJson.toJSONString();
        }
        if (DzConstants.PayType.THIRD_REALTIME_PAY.value().equals(tranInfoVO.getPayTypeCode()))
        {
          PayChannelVO vo = this.payChannelService.queryChannelByCode(tranInfoVO.getChannelCode());
          if (null == vo)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.ChannelErrorCode.NOT_FOUNT.getDesc());
            resultJson.put("errorCode", DzErrorCode.ChannelErrorCode.NOT_FOUNT.value());
            return resultJson.toJSONString();
          }
        }
        if (((DzConstants.PayType.THIRD_REALTIME_PAY.value().equals(tranInfoVO.getPayTypeCode())) || 
          (DzConstants.PayType.CASH_PAY.value().equals(tranInfoVO.getPayTypeCode())) || 
          (DzConstants.PayType.OFFLINE_CARD_PAY.value().equals(tranInfoVO.getPayTypeCode()))) && 
          (!DzConstants.payState.PAY_SUCCESS.value().equals(tranInfoVO.getPayStateCode())))
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAY_STATE_ERROR.getDesc());
          resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAY_STATE_ERROR.value());
          return resultJson.toJSONString();
        }
        if ((StringUtils.isBlank(tranInfoVO.getReceiver())) && (CollectionUtils.isEmpty(tranInfoVO.getTranSubVOList())))
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", DzErrorCode.MerchErrorCode.MERCHANT_IS_REQUIRED.getDesc());
          resultJson.put("errorCode", DzErrorCode.MerchErrorCode.MERCHANT_IS_REQUIRED.value());
          return resultJson.toJSONString();
        }
        if (CollectionUtils.isNotEmpty(tranInfoVO.getTranSubVOList()))
        {
          BigDecimal tmp = BigDecimal.valueOf(0L);
          for (TranSubVO subvo : tranInfoVO.getTranSubVOList()) {
            tmp = BigDecimalUtil.add(tmp, subvo.getPaymentAmount());
          }
          if (BigDecimalUtil.compareTo(tmp, tranInfoVO.getPaymentAmount()) != 0)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAY_AMOUNT_ERROR.getDesc());
            resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAY_AMOUNT_ERROR.value());
            return resultJson.toJSONString();
          }
        }
        Integer userType = Integer.valueOf(0);
        if (DzConstants.CardType.IDENTITY_CARD.value().equals(tranInfoVO.getCardType()))
        {
          if (!DzConstants.PayType.BATCH_PAY.value().equals(tranInfoVO.getPayTypeCode()))
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.getDesc());
            resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.value());
            return resultJson.toJSONString();
          }
          MerchantVO mv = this.merchantDAO.queryMerchantByIdentifyCardNo(tranInfoVO.getCardNo());
          if (null == mv)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", "身份识别卡" + tranInfoVO.getCardNo() + "关联的合作商不存在。");
            resultJson.put("errorCode", DzErrorCode.MerchErrorCode.NOT_FOUND.value());
            return resultJson.toJSONString();
          }
          IdentityAccountVO identityAccountVO = this.dentityAccountDAO.queryUserByIdentifyCardNo(tranInfoVO.getCardNo());
          UserBaseVO userBasevo = new UserBaseVO();
          userBasevo.setUserId(identityAccountVO.getUserId());
          userBasevo = this.userDAOImpl.querySingleUser(userBasevo);
          
          tranInfoVO.setOriginalPayer(userBasevo.getUserId());
          tranInfoVO.setOriginalPayerType(userBasevo.getUserType());
          tranInfoVO.setOriginalPayerName(userBasevo.getName());
          userType = DzConstants.userType.UNIFIEDPAY_CUSTOMER.value();
          
          tranInfoVO.setPayer(mv.getMerchantCode());
          tranInfoVO.setPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
          tranInfoVO.setPayerName(mv.getShortName());
        }
        else if (DzConstants.CardType.ONLINE_CARD.value().equals(tranInfoVO.getCardType()))
        {
          OnlineAccountVO onlineCard = this.onlineAccountDAO.queryOnlineCardByNo(tranInfoVO.getCardNo());
          if (null == onlineCard)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.CardErrorCode.NOT_FOUND.getDesc());
            resultJson.put("errorCode", DzErrorCode.CardErrorCode.NOT_FOUND.value());
            return resultJson.toJSONString();
          }
          UserBaseVO userBasevo = new UserBaseVO();
          userBasevo.setUserId(onlineCard.getUserId());
          userBasevo = this.userDAOImpl.querySingleUser(userBasevo);
          if (null == userBasevo)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.CardErrorCode.NOT_FOUND.getDesc());
            resultJson.put("errorCode", DzErrorCode.CardErrorCode.NOT_FOUND.value());
            return resultJson.toJSONString();
          }
          tranInfoVO.setOriginalPayer(userBasevo.getUserId());
          tranInfoVO.setOriginalPayerType(userBasevo.getUserType());
          tranInfoVO.setOriginalPayerName(userBasevo.getName());
          userType = userBasevo.getUserType();
          if (DzConstants.userType.ENTERPRISE_CUSTOMER.value().equals(userBasevo.getUserType()))
          {
            if (!DzConstants.PayType.ENTERPRISES_PAY.value().equals(tranInfoVO.getPayTypeCode()))
            {
              resultJson.put("isSuccess", Integer.valueOf(0));
              resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.getDesc());
              resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.value());
              return resultJson.toJSONString();
            }
            MerchantVO mv = this.merchantDAO.queryMerchantByCode(userBasevo.getEnterpriseCode());
            if (null == mv)
            {
              resultJson.put("isSuccess", Integer.valueOf(0));
              resultJson.put("errorMsg", DzErrorCode.MerchErrorCode.NOT_FOUND.getDesc());
              resultJson.put("errorCode", DzErrorCode.MerchErrorCode.NOT_FOUND.value());
              return resultJson.toJSONString();
            }
            tranInfoVO.setPayer(mv.getMerchantCode());
            tranInfoVO.setPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
            tranInfoVO.setPayerName(mv.getShortName());
          }
          else
          {
            if ((!DzConstants.PayType.THIRD_REALTIME_PAY.value().equals(tranInfoVO.getPayTypeCode())) && 
              (!DzConstants.PayType.EWALLET_PAY.value().equals(tranInfoVO.getPayTypeCode())) && 
              (!DzConstants.PayType.CASH_PAY.value().equals(tranInfoVO.getPayTypeCode())) && 
              (!DzConstants.PayType.IMPREST_PAY.value().equals(tranInfoVO.getPayTypeCode())))
            {
              resultJson.put("isSuccess", Integer.valueOf(0));
              resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.getDesc());
              resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.value());
              return resultJson.toJSONString();
            }
            tranInfoVO.setPayer(userBasevo.getUserId());
            tranInfoVO.setPayerType(userBasevo.getUserType());
            tranInfoVO.setPayerName(userBasevo.getName());
          }
        }
        else if (DzConstants.CardType.OFFLINE_CARD.value().equals(tranInfoVO.getCardType()))
        {
          tranInfoVO.setOriginalPayerType(DzConstants.userType.OFFLINE_CUSTOMER.value());
          tranInfoVO.setPayerType(DzConstants.userType.OFFLINE_CUSTOMER.value());
          tranInfoVO.setPayer(tranInfoVO.getCardNo());
          tranInfoVO.setOriginalPayer(tranInfoVO.getCardNo());
          userType = DzConstants.userType.OFFLINE_CUSTOMER.value();
          if (!DzConstants.PayType.OFFLINE_CARD_PAY.value().equals(tranInfoVO.getPayTypeCode()))
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.getDesc());
            resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.value());
            return resultJson.toJSONString();
          }
        }
        else if (this.cardTypeService.getAllOuterCardType().contains(tranInfoVO.getCardType()))
        {
          if (!DzConstants.PayType.OUT_OFFLINE_CARD_PAY.value().equals(tranInfoVO.getPayTypeCode()))
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.getDesc());
            resultJson.put("errorCode", DzErrorCode.TranErrorCode.PAYTYPE_NOTMATCH_USERTYPE.value());
            return resultJson.toJSONString();
          }
          tranInfoVO.setOriginalPayerType(DzConstants.userType.OUT_OFFLINE_CUSTOMER.value());
          tranInfoVO.setOriginalPayer(tranInfoVO.getCardNo());
          userType = DzConstants.userType.OUT_OFFLINE_CUSTOMER.value();
          
          OutOfflineCardMerchant out = this.accountingDAO.queryMerchantByCardType(tranInfoVO.getCardType());
          if (null == out) {
            throw new BusinessException(DzErrorCode.MerchErrorCode.NOT_FOUND.value(), "外部离线卡（外部现金卡）类型(" + tranInfoVO.getCardType() + ")未配置关联的运营商", "外部离线卡（外部现金卡）类型未配置关联的运营商");
          }
          tranInfoVO.setPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
          tranInfoVO.setPayer(out.getMerchantCode());
          tranInfoVO.setPayerName(out.getShortName());
        }
        else
        {
          resultJson.put("isSuccess", Integer.valueOf(0));
          resultJson.put("errorMsg", DzErrorCode.CardErrorCode.CARD_TYPE_NOT_EXIST.getDesc());
          resultJson.put("errorCode", DzErrorCode.CardErrorCode.CARD_TYPE_NOT_EXIST.value());
          return resultJson.toJSONString();
        }
        tranInfoVO.setAccountState(DzConstants.accountingState.WAIT_FOR_ACCOUNTING.value());
        tranInfoVO.setPlatTime(DateUtil.getDBCurrentTime());
        tranInfoVO.setAccountingDate(this.commonService.getAccountingDate());
        if (null == userType) {
          userType = Integer.valueOf(8);
        }
        String currentDate = DateUtil.getDateFormatter();
        String seqNo = DZStringUtil.getFixedLengthString(8, String.valueOf(this.tradeDAO.querySequence("seq_trade_no")));
        String tradNo = String.valueOf(userType) + tranInfoVO.getAppId() + currentDate + seqNo;
        String subSeqNo = null;
        
        tranInfoVO.setTradeNo(tradNo);
        

        MerchantVO tmpMerch = null;
        for (TranSubVO tranSub : tranInfoVO.getTranSubVOList())
        {
          if ((StringUtils.isBlank(tranSub.getServiceNo())) || (StringUtils.isBlank(tranSub.getReceiver())) || 
            (null == tranSub.getPaymentAmount()))
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.CommonErrorCode.PARAM_REQUIRED.getDesc());
            resultJson.put("errorCode", DzErrorCode.CommonErrorCode.PARAM_REQUIRED.value());
            return resultJson.toJSONString();
          }
          serviceVO = this.orderService.queryServiceByCode(tranSub.getServiceNo());
          if (null == serviceVO)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.TranErrorCode.SERVICE_NOT_FOUND.getDesc() + ",服务编码为：" + tranSub.getServiceNo());
            resultJson.put("errorCode", DzErrorCode.TranErrorCode.SERVICE_NOT_FOUND.value());
            return resultJson.toJSONString();
          }
          subSeqNo = DZStringUtil.getFixedLengthString(8, String.valueOf(this.tradeDAO.querySequence("seq_trade_sub_no")));
          
          tmpMerch = this.merchantDAO.queryMerchantByCode(tranSub.getReceiver());
          if (null == tmpMerch)
          {
            resultJson.put("isSuccess", Integer.valueOf(0));
            resultJson.put("errorMsg", DzErrorCode.MerchErrorCode.NOT_FOUND.getDesc() + ";运营商编码为：" + tranSub.getReceiver());
            resultJson.put("errorCode", DzErrorCode.MerchErrorCode.NOT_FOUND.value());
            return resultJson.toJSONString();
          }
          tranSub.setReceiverType(DzConstants.userType.MERCHANT_CUSTOMER.value());
          tranSub.setReceiverBalType(tmpMerch.getBalType());
          tranSub.setReceiverName(tmpMerch.getShortName());
          tranSub.setReceiverIsSelf(tmpMerch.getIsSelf());
          if ((StringUtils.isBlank(tranInfoVO.getReceiver())) && 
            (DzConstants.isSelfMerchant.SELF.value().equals(tmpMerch.getIsSelf())))
          {
            tranInfoVO.setReceiver(tmpMerch.getMerchantCode());
            tranInfoVO.setReceiverType(DzConstants.userType.MERCHANT_CUSTOMER.value());
          }
          tranSub.setTradeNo(tradNo);
          tranSub.setSubTradeNo(currentDate + subSeqNo);
        }
        int n = this.tradeDAO.insertTranInfo(tranInfoVO);
        if (n == 0) {
          throw new BusinessException(DzErrorCode.TranErrorCode.SAVE_TRAN_INFO_FAIL.value(), DzErrorCode.TranErrorCode.SAVE_TRAN_INFO_FAIL.getDesc(), DzErrorCode.TranErrorCode.SAVE_TRAN_INFO_FAIL.getDesc());
        }
        int[] sub = this.tradeDAO.batchInsertTranSubInfo(tranInfoVO.getTranSubVOList());
        if (sub == null) {
          throw new BusinessException(DzErrorCode.TranErrorCode.SAVE_TRAN_SUB_INFO_FAIL.value(), DzErrorCode.TranErrorCode.SAVE_TRAN_SUB_INFO_FAIL.getDesc(), DzErrorCode.TranErrorCode.SAVE_TRAN_SUB_INFO_FAIL.getDesc());
        }
        for (int i : sub) {
          if (i == 0) {
            throw new BusinessException(DzErrorCode.TranErrorCode.SAVE_TRAN_SUB_INFO_FAIL.value(), DzErrorCode.TranErrorCode.SAVE_TRAN_SUB_INFO_FAIL.getDesc(), DzErrorCode.TranErrorCode.SAVE_TRAN_SUB_INFO_FAIL.getDesc());
          }
        }
      }
      resultJson.put("isSuccess", Integer.valueOf(1));
    }
    catch (JSONException e)
    {
      LogUtil.error("json转换异常", e);
      

      throw new BusinessException(DzErrorCode.CommonErrorCode.FORMAT_ERROR.value(), DzErrorCode.CommonErrorCode.FORMAT_ERROR.getDesc(), DzErrorCode.CommonErrorCode.FORMAT_ERROR.getDesc() + ",请检查数据格式，尤其是日期格式yyyy-MM-dd HH:mm:ss");
    }
    return resultJson.toJSONString();
  }
  
  public static void main(String[] args)
  {
    try
    {
      String json = "{\"accountingDate\":\"2016-1-19 12:01:01\",\"paymentAmount\":\"35.002\",\"tranSubVOList\":[{\"serviceNo\":\"0002\"},{\"serviceNo\":\"0002\"}]}";
      












      System.out.println(DzErrorCode.CommonErrorCode.PARAM_REQUIRED.value());
      TranInfoVO v = (TranInfoVO)JSONObject.parseObject(json, TranInfoVO.class);
      SimpleDateFormat d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      System.out.println(d.format(v.getAccountingDate()));
      System.out.println(((TranSubVO)v.getTranSubVOList().get(0)).getServiceNo());
    }
    catch (JSONException e)
    {
      System.out.println("aaaaaaa");
      e.printStackTrace();
    }
    catch (Exception e)
    {
      System.out.println("dddddddddddd");
      e.printStackTrace();
    }
  }
}
